package functest;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class SelHB extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        String stjc = new String(request.getParameter("jcname").getBytes("ISO8859-1"), "UTF-8");
        String enjc = new String(request.getParameter("jcname1").getBytes("ISO8859-1"), "UTF-8");
        String month = new String(request.getParameter("month").getBytes("ISO8859-1"), "UTF-8");
        String day = new String(request.getParameter("day").getBytes("ISO8859-1"), "UTF-8");
        String name = request.getParameter("name");
        String userid = request.getParameter("userid");
        String tkid = request.getParameter("tkid");
        if (stjc.equals("0") || enjc.equals("0") || month.equals("0") || day.equals("0"))
            response.sendRedirect("../error1.html");
        else
            try {
                FindAPrint test = new FindAPrint();
                List<Map<String, String>> list = test.Findhx(stjc, enjc);
                list = test.checktime(list, month, day);
                request.setAttribute("hxlist", list);
                if (name == null){
                    request.getRequestDispatcher("../buypg2.jsp").forward(request, response);
                }
                else {
                    request.setAttribute("name",name);
                    request.setAttribute("userid",userid);
                    request.setAttribute("tkid",tkid);
                    request.getRequestDispatcher("../buypg2.jsp").forward(request, response);
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }
    }
}
